package mx.netbrain.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

import org.apache.log4j.Logger;

public class ConnectionMySQL {

	private static final Logger logger = Logger
			.getLogger(ConnectionMySQL.class);

	public static boolean test(String driver, String host, String user,
			String password) {
		try {
			Statement stmt;
			Class.forName(driver);
			Connection con = DriverManager.getConnection(host, user, password);
			stmt = con.createStatement();
			boolean result;
			result = stmt.execute("show tables;");
			if (result) {
				logger.info("Host: " + host + " User: " + user + " Password: "
						+ "*****");
				return true;
			}
			con.close();
			stmt.close();
		} catch (Exception e) {
			logger.error(e);
		}
		return false;
	}

}
